var factory = sy.getModule('myApp',['infinite-scroll']);
	// 创建后台数据交互工厂（分页）
	factory.factory('store', function ($http) {
	    var Demo = function () {
	        this.items = {};
	    };
	        
        Demo.prototype.query = function (id) {
        	this.items={};
            sy.openLoad();
	        $http.post('/m/store/detail',{
				id:id
			}).success(function (data) {
				sy.closeLoad();
				if(data){
					this.items = data;
					initMap(data.lng,data.lat);
				}
	        }.bind(this)).error(function(data, status) {
	        	sy.closeLoad();
			});
        };
	    return Demo;
	});
	
	
	// 申明页面控制类、
	factory.controller('mapController',['$http','$scope','store',
	   	function ($http,$scope, store) {
		     $scope.store = new store();
		     $scope.store.query(_id);
		}
	]);
	var map;
	function initMap(lng,lat){
		console.log(sessionStorage.areaName)
		map = new AMap.Map('container', {
	        resizeEnable: true,
	        zoom:11,
	        center: [lng, lat]
	        
	    });
		var trans;
	    transOptions = {
	        map: map,
	        city: sessionStorage.areaName,                            //公交城市
	        policy: AMap.TransferPolicy.LEAST_TIME //乘车策略
	    };
	    //构造公交换乘类
	    trans = new AMap.Transfer(transOptions);
	    //根据起、终点坐标查询公交换乘路线
	    trans.search([sessionStorage.geoLng, sessionStorage.geoLat], [lng, lat]);
	}
	
	